<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class ChangeSpiderLogsToUserAuthSpiderTransLogs extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('user_auth_spider_trans_logs', function (Blueprint $table) {
            //
            $table->dropUnique('user_auth_spider_trans_logs_loan_request_id_unique');
            $table->dropColumn(['phone_trade_no','phone_status','zhima_trade_no','zhima_status','phone_failed_reason','zhima_failed_reason']);
            $table->string('trade_no')->default('')->comment('爬虫tradeNo');
            $table->tinyInteger('status')->default(1)->comment('爬虫状态 1=原始状态 2=成功 3=失败');
            $table->string('failed_reason')->default('')->comment('失败原因');
            $table->string('type')->default('')->comment('carrier:运营商;taobao:淘宝;jingdong:京东;alipay:支付宝; fund:公积金; insure:社保; ibank:储蓄卡信息; icredit:信用卡信息; wld:微粒贷认证;');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('user_auth_spider_trans_logs', function (Blueprint $table) {
            //
            $table->unique('loan_request_id');
            $table->string('phone_trade_no')->default('')->comment('运营商trade编号');
            $table->tinyInteger('phone_status')->default(1)->comment('运营商爬虫状态 1=原始状态 2=成功 3=失败');
            $table->string('zhima_trade_no')->default('')->comment('芝麻信用trade编号');
            $table->tinyInteger('zhima_status')->default(1)->comment('芝麻信用爬虫状态 1=原始状态 2=成功 3=失败');
            $table->string('phone_failed_reason')->default('')->comment('运营商失败原因');
            $table->string('zhima_failed_reason')->default('')->comment('芝麻信用失败原因');
            $table->dropColumn(['trade_no','status','failed_reason','type']);
        });
    }
}
